from django.db import models


# Create your models here.

class Player(models.Model):
    name = models.CharField("姓名", max_length=11, unique=True)

    class Meta:
        verbose_name = "玩家/客户端"
        verbose_name_plural = "玩家/客户端"
        indexes = [
            models.Index(fields=['id', 'name']),
        ]


class Score(models.Model):
    player = models.ForeignKey(Player, on_delete=models.DO_NOTHING, null=True)
    score = models.IntegerField('分数', default=0)

    class Meta:
        verbose_name = "得分"
        verbose_name_plural = "得分"


class Charts(models.Model):
    player = models.OneToOneField(Player, on_delete=models.DO_NOTHING, null=True)
    score = models.IntegerField('分数', default=0)

    class Meta:
        verbose_name = "排行榜"
        verbose_name_plural = "排行榜"
        indexes = [
            models.Index(fields=['player', 'score']),
        ]
